#pragma once
#include "resource.h"
#include "ChartViewer.h"
#include "afxwin.h"
#include "DefineCol.h"
#include "Global.h"
// CFinanceDlg dialog

class CFinanceDlg : public CDialog
{
	DECLARE_DYNAMIC(CFinanceDlg)

public:
	CFinanceDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CFinanceDlg();

// Dialog Data
	enum { IDD = IDD_FINANCE_DIALOG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	CComboBox m_AvgType1;
	CComboBox m_AvgType2;
	CComboBox m_Band;
	CComboBox m_ChartSize;
	CComboBox m_ChartType;
	CChartViewer m_ChartViewer;
	CEdit m_CompareWith;
	CComboBox m_Indicator1;
	CComboBox m_Indicator2;
	CComboBox m_Indicator3;
	CComboBox m_Indicator4;
	CButton m_LogScale;
	CEdit m_MovAvg1;
	CEdit m_MovAvg2;
	CButton m_ParabolicSAR;
	CButton m_PercentageScale;
	CEdit m_TickerSymbol;
	CComboBox m_Product;
	CButton m_Volume;
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	void InitProductList();



	// The resolution of the data in seconds. 1 day = 86400 seconds.
	int m_resolution;

	// The moving average periods
	int m_avgPeriod1;
	int m_avgPeriod2;

	// Draw the chart
	virtual void drawChart(CChartViewer *viewer);


	double m_timeStamps[MAX_COUNT];
	double m_volData[MAX_COUNT];
	double m_highData[MAX_COUNT];
	double m_lowData[MAX_COUNT];
	double m_openData[MAX_COUNT];
	double m_closeData[MAX_COUNT];
	double m_BandHH[MAX_COUNT];
	double m_BandHL[MAX_COUNT];
	double m_BandLH[MAX_COUNT];
	double m_BandLL[MAX_COUNT];
	double m_DayH[MAX_COUNT];
	double m_DayL[MAX_COUNT];

	int m_noOfPoints;

	afx_msg void OnSelectChange();
	afx_msg void OnTextChange();


	void SetData(ChartDataList* a_DataList);
	void SetData(CChartMultiData* a_Data);
	void SetBandData();
	void SetDayHighLow();
	afx_msg void OnCbnSelchangeTimerange();
	int AddMonoWaves(XYChart* pMainChart);
	int DrawWave(const ETime& startDate, double startPrice, const ETime& endDate, double endPrice, double* pts);

	//Start date of the data points (excluding extra leading points)
	double m_startDate;
	//End date of the data points.
	double m_endDate;
	int m_leadingExtraPoints;
	int m_offsetIntoRawArrays;

	// Initialize the CChartViewer
	void initChartViewer(CChartViewer *viewer);

	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	afx_msg void OnViewPortChanged();
	afx_msg void OnMouseMovePlotArea();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);

	// Update controls when the view port changed
	void updateControls(CChartViewer *viewer);
	// // Horizontal Scroll Bar.
	CScrollBar m_HScrollBar;
	void trackLineLabel(XYChart *c, int mouseX);
	void DrawArrow(XYChart* c, DrawArea* d, string a_Name, int a_Time, int a_X, int a_Y, int a_Size, int a_Direc);
};
